﻿using BCDto.Common.ErrorMessage;
using BCDto.Location.Driver;
using BCDto.Location.Horseman;
using BCService.TMS.Location;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace BCTMSRESTful.Controllers.ClientApp.Location
{
    /// <summary>
    /// 保价配置
    /// </summary>
    [Route("api/v1/ClientApp/[controller]")]
    [ApiExplorerSettings(GroupName = "ClientApp")]
    public class LocationController : ClientAppBaseController
    {
        private readonly ILocationService locationService;

        public LocationController(ILocationService locationService)
        {
            this.locationService = locationService;
        }

        #region 获取订单取货地附近司机列表
        /// <summary>
        /// 获取订单取货地附近司机列表
        /// </summary>
        /// <response code="200">附近司机列表</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]/{order_id}")]
        [ProducesResponseType(typeof(IEnumerable<DriverLocationNearDto>), 200)]
        [ProducesResponseType(typeof(ErrorMessageDto), 400)]
        [ProducesResponseType(typeof(ErrorMessageDto), 500)]
        public IActionResult QueryNearDrivers([FromRoute(Name = "order_id")] long orderId,
            [FromQuery(Name = "max_distance")] int maxDistance)
        {
            return Ok(this.locationService.QueryNearDrivers(orderId,  maxDistance));
        }
        #endregion

        #region 获取订单取货地附近骑手列表
        /// <summary>
        /// 获取订单取货地附近骑手列表
        /// </summary>
        /// <response code="200">附近骑手列表</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]/{order_id}")]
        [ProducesResponseType(typeof(IEnumerable<HorsemanLocationNearDto>), 200)]
        [ProducesResponseType(typeof(ErrorMessageDto), 400)]
        [ProducesResponseType(typeof(ErrorMessageDto), 500)]
        public IActionResult QueryNearHorsemen([FromRoute(Name = "order_id")] long orderId,
            [FromQuery(Name = "max_distance")] int maxDistance)
        {
            return Ok(this.locationService.QueryNearHorsemen(orderId,  maxDistance));
        }
        #endregion
    }
}
